/*
 *  $Id: FeatheredFlock.cs 1067 2010-05-21 11:00:43Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Spells {
    public class FeatheredFlock: SelfEnchantmentCard {
        public FeatheredFlock(): base("001_a_s_feathered_flock") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Value = 100;
            AddManaCost(ElementType.Air, 2);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new FeatheredFlockAffect();
        }

        private class FeatheredFlockAffect: EnchantmentAffect<FeatheredFlock> {
            public FeatheredFlockAffect() {
                Add(new FeatheredFlockAura());
            }
        }

        private class FeatheredFlockAura: Affects.FlightAura {
            public FeatheredFlockAura(): base(true, false) {}

            public override string Id {
                get { return AffectManager.GetCardId<FeatheredFlock>("aura"); }
            }

            protected override Affect CreateSubAffect() {
                return new FeatheredFlockAuraAffect();
            }

            public override void SetAffect() {
                base.SetAffect();
                GlobalSummary.AddVanguard(OnlyFly);
            }

            public override void ResetAffect() {
                base.ResetAffect();
                GlobalSummary.RemoveVanguard(OnlyFly);
            }

            private static bool OnlyFly(Creature cr) { return cr.CanFly; }
        }

        private class FeatheredFlockAuraAffect: SpellAffect<FeatheredFlock> {
            public FeatheredFlockAuraAffect() {
                Add(new Affects.MoveTireless());
                Add(new Affects.Vanguard());
            }
        }
    }
}
